//
//  UILabel+extense.m
//  DecoAware
//
//  Created by APP on 16/4/19.
//  Copyright © 2016年 Sunyoung. All rights reserved.
//

#import "UILabel+extense.h"

@implementation UILabel (extense)
/**
 根据Lable的内容和国定宽度
 获取Label的真实高度
 */
-(CGSize) getLabelContentSize
{
    CGSize labelRealContensize = [self.text boundingRectWithSize:CGSizeMake(self.bounds.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.font} context:nil].size;
    
    //     CGSize size = CGSizeMake(self.bounds.size.width,CGFLOAT_MAX);//LableWight标签宽度，固定的
    //计算实际frame大小，并将label的frame变成实际大小
    //     labelRealContensize = [self.text sizeWithFont:self.font constrainedToSize:size lineBreakMode:self.lineBreakMode];
    //self.bounds.size.width 计算自身的宽度
    return labelRealContensize;
}



//CGSize titleSize = [aString sizeWithFont:font constrainedToSize:CGSizeMake(MAXFLOAT, 30)];
/**
 根据Lable的内容和国定高度
 获取Label的真实宽度
 */
-(CGSize) getLabelContentSizeForWidth
{
    
    CGSize labelRealContensize = [self.text boundingRectWithSize:CGSizeMake(MAXFLOAT,self.bounds.size.height) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.font} context:nil].size;
    
    // CGSize labelRealContensize = [self.text sizeWithFont:self.font constrainedToSize:CGSizeMake(MAXFLOAT, self.bounds.size.height)];
    
    return labelRealContensize;
}
@end
